/**
 */
package Entityrelationship.entityrelationship.impl;

import Entityrelationship.entityrelationship.Connection_E_R_Restriction;
import Entityrelationship.entityrelationship.Connection_Entity_Relationship;
import Entityrelationship.entityrelationship.EntityrelationshipPackage;
import Entityrelationship.entityrelationship.TypeRestriction2;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Connection ERRestriction</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link Entityrelationship.entityrelationship.impl.Connection_E_R_RestrictionImpl#getType_restriction <em>Type restriction</em>}</li>
 *   <li>{@link Entityrelationship.entityrelationship.impl.Connection_E_R_RestrictionImpl#getConnections_entity_relationship <em>Connections entity relationship</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class Connection_E_R_RestrictionImpl extends C_E_R_R_InclusivenessImpl implements Connection_E_R_Restriction {
	/**
	 * The default value of the '{@link #getType_restriction() <em>Type restriction</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType_restriction()
	 * @generated
	 * @ordered
	 */
	protected static final TypeRestriction2 TYPE_RESTRICTION_EDEFAULT = TypeRestriction2.EXCLUSIVENESS;

	/**
	 * The cached value of the '{@link #getType_restriction() <em>Type restriction</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType_restriction()
	 * @generated
	 * @ordered
	 */
	protected TypeRestriction2 type_restriction = TYPE_RESTRICTION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getConnections_entity_relationship() <em>Connections entity relationship</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConnections_entity_relationship()
	 * @generated
	 * @ordered
	 */
	protected EList<Connection_Entity_Relationship> connections_entity_relationship;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Connection_E_R_RestrictionImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return EntityrelationshipPackage.Literals.CONNECTION_ERRESTRICTION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TypeRestriction2 getType_restriction() {
		return type_restriction;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType_restriction(TypeRestriction2 newType_restriction) {
		TypeRestriction2 oldType_restriction = type_restriction;
		type_restriction = newType_restriction == null ? TYPE_RESTRICTION_EDEFAULT : newType_restriction;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, EntityrelationshipPackage.CONNECTION_ERRESTRICTION__TYPE_RESTRICTION, oldType_restriction, type_restriction));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Connection_Entity_Relationship> getConnections_entity_relationship() {
		if (connections_entity_relationship == null) {
			connections_entity_relationship = new EObjectResolvingEList<Connection_Entity_Relationship>(Connection_Entity_Relationship.class, this, EntityrelationshipPackage.CONNECTION_ERRESTRICTION__CONNECTIONS_ENTITY_RELATIONSHIP);
		}
		return connections_entity_relationship;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case EntityrelationshipPackage.CONNECTION_ERRESTRICTION__TYPE_RESTRICTION:
				return getType_restriction();
			case EntityrelationshipPackage.CONNECTION_ERRESTRICTION__CONNECTIONS_ENTITY_RELATIONSHIP:
				return getConnections_entity_relationship();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case EntityrelationshipPackage.CONNECTION_ERRESTRICTION__TYPE_RESTRICTION:
				setType_restriction((TypeRestriction2)newValue);
				return;
			case EntityrelationshipPackage.CONNECTION_ERRESTRICTION__CONNECTIONS_ENTITY_RELATIONSHIP:
				getConnections_entity_relationship().clear();
				getConnections_entity_relationship().addAll((Collection<? extends Connection_Entity_Relationship>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case EntityrelationshipPackage.CONNECTION_ERRESTRICTION__TYPE_RESTRICTION:
				setType_restriction(TYPE_RESTRICTION_EDEFAULT);
				return;
			case EntityrelationshipPackage.CONNECTION_ERRESTRICTION__CONNECTIONS_ENTITY_RELATIONSHIP:
				getConnections_entity_relationship().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case EntityrelationshipPackage.CONNECTION_ERRESTRICTION__TYPE_RESTRICTION:
				return type_restriction != TYPE_RESTRICTION_EDEFAULT;
			case EntityrelationshipPackage.CONNECTION_ERRESTRICTION__CONNECTIONS_ENTITY_RELATIONSHIP:
				return connections_entity_relationship != null && !connections_entity_relationship.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (type_restriction: ");
		result.append(type_restriction);
		result.append(')');
		return result.toString();
	}

} //Connection_E_R_RestrictionImpl
